var sw1 = new Swiper('.swiper-container', {
    loop: true,
    spaceBetween: 30,
    centeredSlides: true,

    autoplay: {
        delay: 2500,
        disableOnInteraction: false,
    },
    pagination: {
        el: '.swiper-pagination',
        clickable: true,
    },
    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
    },
});

var md = document.querySelectorAll(".main > div")
for(let i = 0;i<md.length;i++){
    md[i].style.display = "none";
}
md[0].style.display = "block";


//返回顶部
var haha = document.querySelector("#haha");
var haha2 = document.querySelector("#haha2");
var to2top = document.querySelector("#to-top");
window.onscroll = function(){
    console.log(document.documentElement.scrollTop || document.body.scrollTop);
};
to2top.addEventListener('click',function(){
    window.scrollTo({
        top:0,
        behavior:'smooth'
    });
});

//显示和隐藏
var two1 = document.querySelector("#two1");
var one1 = document.querySelector("#one");
two1.addEventListener("click",function(){
    one1.style.display = "block";

});
two1.addEventListener("mouseout",function(){
    one1.style.display = "none";
});
one1.addEventListener("mouseover",function(){
    one1.style.display = "block";
});
one1.addEventListener("mouseout",function(){
    one1.style.display = "none";
});



new Vue({
    el:'#app',
    data:{
        mess:'..'
    },
    mounted(){
        axios
            .get('json/news.json')
            .then(response => this.mess = response.data.urls)
            .catch (function(error){
                console.log(error);
            })
    }
});

var  nav = document.querySelectorAll('.nav > li');
var main = document.querySelectorAll('.main > div');

for (var i = 0;i<nav.length; i++){
    nav[i].index = i;
    nav[i].addEventListener('click',function(){


        for(var j= 0; j<nav.length; j++){
            nav[j].classList.remove('active');
            main[j].classList.remove('active');
        }
        console.log(this);
        console.log(this.index);
        this.classList.add('active');
        main[this.index].classList.add('active');



        for(let j = 0;j<md.length;j++){
            md[j].style.display = "none";
        }
        md[this.index].style.display = "block";

    })
}










